<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="cc.woori.mobile.bean.ChurchServiceEntry2" %>
<%@ page import="cc.woori.mobile.PMF" %>
<%@ page import="javax.jdo.Extent" %>
<%@ page import="javax.jdo.Query" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="com.google.appengine.api.datastore.KeyFactory" %>
<%@ page import="java.text.SimpleDateFormat" %>
<div id="listofservices">
	<div class="toolbar">
		<a href="#" class="back" >뒤로</a>
		<h1>우리들 교회 설명</h1>
	</div>
	<ul class="rounded">
	<%
    		PersistenceManager pm = PMF.get().getPersistenceManager();
			SimpleDateFormat sdf = new SimpleDateFormat("yyyy년 MM월 dd일");
    		try{ 
	    		Query query = pm.newQuery(ChurchServiceEntry2.class);
	    		query.setOrdering("publishDate desc");
	    		query.setRange(0,30);
	    		
	    		List<ChurchServiceEntry2> results = (List<ChurchServiceEntry2>) query.execute();
	    		
	    		for (ChurchServiceEntry2 e : results) {
	    			System.out.println(KeyFactory.keyToString(e.getKey()));
	    			System.out.println(e.getTitle());
	    %>
		<li class="arrow"> 
			<a href="/pages/detail/svcinfo.jsp?vid=<%=KeyFactory.keyToString(e.getKey())%>" onClick="javascript: pageTracker._trackPageview('/sermons/detail');">
			<font size="5" color="#96b1d2"><b><%=e.getTitle()%></b> (<%=e.getPastor()%>)</font><br />
			<font size="2">일시: <%=sdf.format(e.getPublishDate()) %>, 본문: <%=e.getVerse() %></font>
			</a>
			
		</li>
	<%
    		}//end for
		}finally{
			if(pm != null){
				pm.close();
			}
		}
   	%>

	</ul>
</div>    